package com.wizz.trade.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wizz.trade.auth.dto.SysMenuDto;
import com.wizz.trade.auth.dto.page.SysMenuPageDto;
import com.wizz.trade.auth.entity.SysMenu;
import com.wizz.trade.auth.mapper.SysMenuMapper;
import com.wizz.trade.auth.service.SysMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wizz.trade.auth.vo.SysMenuVo;
import com.wizz.trade.common.ServiceException;
import com.wizz.trade.util.PageUtil;
import com.wizz.trade.common.PageVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单表 服务实现类
 * </p>
 *
 * @author fyftless
 * @since 2023-04-02 04:26:06
 */
@Service
@Slf4j
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {

    @Resource
    private SysMenuMapper sysMenuMapper;

    @Override
    public Long getParentId(Long id) {
        return null;
    }

    @Override
    public PageVo<SysMenu> getPage(SysMenuPageDto sysMenuDto) {
        IPage<SysMenu> page = sysMenuMapper.getPage(PageUtil.initPage(sysMenuDto), sysMenuDto);
        return new PageVo<>(page);
    }

    @Override
    public void insert(SysMenu menu) {
        sysMenuMapper.insert(menu);
    }

    @Override
    public void delete(Long id) {
        sysMenuMapper.logicDelete(id);
    }

    @Override
    public void changeStatus(Long id) {
        sysMenuMapper.changeStatus(id);
    }

    @Override
    public void update(SysMenu menu) {
        sysMenuMapper.updateById(menu);
    }

    @Override
    public List<String> getMenusByUserId(Long id) {
        return sysMenuMapper.getMenusByUserId(id);
    }

    @Override
    public List<SysMenuVo> getMenusVoList(Long id) {
        return sysMenuMapper.getMenusVoList(id);
    }


}
